package p7;

/**
 * @author krystal
 * @date 2022/11/11 20:16
 */
class Animal{
    String name;
    String color;
    int age;

    static {
        System.out.println("Animal的静态代码块");
    }

    {
        System.out.println("Animal的实例代码块");
    }

    public Animal(String name, String color, int age) {
        this.name = name;
        this.color = color;
        this.age = age;
        System.out.println("Animal的构造方法");
    }

    public void eat(){
        System.out.println(name+"正在吃饭");
    }

    public void sleep(){
        System.out.println(name+"正在睡觉");
    }
}

class Dog extends Animal{
    static {
        System.out.println("Dog的静态代码块");
    }

    {
        System.out.println("Dog的实例代码块");
    }

    public Dog(String name, String color, int age) {
        super(name, color, age);
        System.out.println("Dog的构造方法");
    }

    public void bark(){
        System.out.println(name+"汪汪汪~");
    }
}

class Cat extends Animal{
    public Cat(String name, String color, int age) {
        super(name, color, age);
    }

    public void miao(){
        System.out.println(name+"喵喵喵~");
    }
}

public class Demo2 {
    public static void main(String[] args) {
        Dog dog=new Dog("vv","white",2);
        System.out.println("===========");
        Dog dog2=new Dog("vv","white",2);
    }
}
